﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Drawing;

namespace smallDeimos.Game
{
    public partial class News : System.Web.UI.Page
    {
        int UserId;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["sd_id"] != null)
            {
                HttpCookie cookie2 = Request.Cookies["sd_id"];
                UserId = int.Parse(cookie2.Value);
            }
            else
            {
                Session["Error"] = "Cookie sd_id doesn't exists";
                Response.Redirect("~/Error.aspx");
                return;
            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string msg = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Message"));
                if (msg.Contains("Incoming fleet of") == true)
                    e.Row.Cells[0].BackColor = Color.DarkRed;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            StoredProcedures.RemoveAllNews(UserId);
            Page.Response.Redirect(Page.Request.Url.ToString());
        }
    }
}
